/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.manage.convertor;

import cn.hutool.core.bean.BeanUtil;
import info.peigen.hotpot.business.customer.core.domain.partner.Partner;
import info.peigen.hotpot.business.customer.core.repository.entity.PartnerEntity;
import info.peigen.hotpot.business.customer.manage.form.PartnerManageCreateForm;
import info.peigen.hotpot.business.customer.manage.form.PartnerManageEditForm;
import info.peigen.hotpot.business.customer.manage.form.PartnerManageSearchForm;
import info.peigen.hotpot.business.customer.manage.info.PartnerManageInfo;
import info.peigen.hotpot.common.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * <b>(PartnerManageConvertor)</b>
 * 管理后台领域对象 "合作伙伴" 转换器
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023-09-09
 */
@SuppressWarnings("unused")
@Slf4j
public class PartnerManageConvertor {
    // ConvertToEntity
    public static PartnerEntity convertToEntity(Partner domain) {
        return BeanUtil.copyProperties(domain, PartnerEntity.class);
    }

    public static PartnerEntity convertToEntity(PartnerManageInfo info) {
        return BeanUtil.copyProperties(info, PartnerEntity.class);
    }

    public static PartnerEntity convertToEntity(PartnerManageSearchForm form) {
        return BeanUtil.copyProperties(form, PartnerEntity.class);
    }

    public static PartnerEntity convertToEntity(PartnerManageCreateForm form) {
        if (form.getPartnerId() == null) {
            form.setPartnerId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, PartnerEntity.class);
    }

    public static PartnerEntity convertToEntity(PartnerManageEditForm form) {
        return BeanUtil.copyProperties(form, PartnerEntity.class);
    }

    // ConvertToDomain
    public static Partner convertToDomain(PartnerEntity entity) {
        return BeanUtil.copyProperties(entity, Partner.class);
    }

    public static Partner convertToDomain(PartnerManageInfo info) {
        return BeanUtil.copyProperties(info, Partner.class);
    }

    public static Partner convertToDomain(PartnerManageSearchForm form) {
        return BeanUtil.copyProperties(form, Partner.class);
    }

    public static Partner convertToDomain(PartnerManageCreateForm form) {
        if (form.getPartnerId() == null) {
            form.setPartnerId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, Partner.class);
    }

    public static Partner convertToDomain(PartnerManageEditForm form) {
        return BeanUtil.copyProperties(form, Partner.class);
    }

    // convertToInfo
    public static PartnerManageInfo convertToInfo(Partner domain) {
        return BeanUtil.copyProperties(domain, PartnerManageInfo.class);
    }

    public static PartnerManageInfo convertToInfo(PartnerEntity entity) {
        return BeanUtil.copyProperties(entity, PartnerManageInfo.class);
    }

    public static PartnerManageInfo convertToInfo(PartnerManageSearchForm form) {
        return BeanUtil.copyProperties(form, PartnerManageInfo.class);
    }

    public static PartnerManageInfo convertToInfo(PartnerManageCreateForm form) {
        if (form.getPartnerId() == null) {
            form.setPartnerId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, PartnerManageInfo.class);
    }

    public static PartnerManageInfo convertToInfo(PartnerManageEditForm form) {
        return BeanUtil.copyProperties(form, PartnerManageInfo.class);
    }
}